﻿using System;
using System.Windows;
using System.Windows.Controls;
using Heyo.Controls.Animations;

namespace Heyo.Controls
{
    class MaterialFloatingBox : WaveClick
    {
        Viewbox _viewbox;
        public MaterialFloatingBox()
        {
            _viewbox = new Viewbox();
            //base.Child = _viewbox;
            ShadowAnim = true;
            Opacity = 0;
            Visibility = Visibility.Collapsed;
            AnimationSpeed = 8;
            //DownRadius = 10;
            //ShadowOpacity = 0.2;
            Loaded += (s, e) => {
                _originWidth = Width;
                _originHeight = Height;
            };

        }
        public new UIElement Child
        {
            get => _viewbox.Child;
            set => _viewbox.Child = value;
        }
        private double _originWidth, _originHeight;
        public void Show()
        {
            Visibility = Visibility.Visible;
            //SetSizeWithOutAnim(0, 0);
            Width = _originWidth;
            Height = _originHeight;
            Opacity = 1;
        }
        public void Hide()
        {
            Width = 0;
            Height = 0;
            Opacity = 0;
            //SizeAnim.Completed += SizeAnim_Completed;
        }

        private void SizeAnim_Completed(object sender, EventArgs e)
        {
            Visibility = Visibility.Collapsed;
            //SizeAnim.Completed -= SizeAnim_Completed;
        }
    }
}
